#ifndef DLGMAIN_H
#define DLGMAIN_H

#include <QDialog>

#include <QtCore>
#include <QFile>
#include <QSettings>
#include <QFileDialog>
#include <QTimer>
#include <QMessageBox>

namespace Ui {
class DlgMain;
}

class DlgMain : public QDialog
{
    Q_OBJECT

public:
    explicit DlgMain(QWidget *parent = 0);
    ~DlgMain();

    void init();

    void jsonConnect();
    void motorConnect();
    void audioConnect();

signals:
    //=========json=======
    void sig_loadJsonFile(QString filePath);
    void sig_loadJsonByName(QString m_Name);
    void sig_loadJsonByClass(QString m_Class);
    void sig_loadJsonByContent(QString m_Content);
    void sig_stop();
    void sig_getJsonList();
    void sig_getJsonState();

    //=======Motor==========
    //head
    void sig_headEnable();
    void sig_headPowerDown();
    void sig_headLRInit();
    void sig_headUDInit();
    void sig_headLRAngle(int nAngle,int nSpeed);
    void sig_headUDAngle(int nAngle,int nSpeed);
    //left hand
    void sig_handLEnable();
    void sig_handLPowerDown();
    void sig_handLSwingInit();
    void sig_handLExpandInit();
    void sig_handLSwingAngle(int nAngle,int nSpeed);
    void sig_handLExpandAngle(int nAngle,int nSpeed);
    //right hand
    void sig_handREnable();
    void sig_handRPowerDown();
    void sig_handRSwingInit();
    void sig_handRExpandInit();
    void sig_handRSwingAngle(int nAngle,int nSpeed);
    void sig_handRExpandAngle(int nAngle,int nSpeed);
    //wheel
    void sig_wheelEnable();
    void sig_wheelPowerDown();
    void sig_wheelStop(bool bStopAbrupt);
    void sig_wheelRunRotate(int nAngle,int nSpeed);
    void sig_wheelRun(int nDistance,int nSpeed);
    void sig_wheelRunDiff(bool bLeft,int nLeftSpeed,bool bRight,int nRightSpeed);
    //sensor
    void sig_sensorBattery();
    void sig_sensorSonic();
    void sig_sensorInfrared();
    void sig_sensorWheel();
    //led
    void sig_ledHeadEye(int nIndexF,int nIndexB);
    void sig_ledHeadEye2(int nDelay,bool nR,bool nG,bool nB);
    void sig_ledHeadEar(int nDelay,bool nR,bool nG,bool nB);
    void sig_ledBodyLed(int nDelay,bool nR,bool nG,bool nB);
    void sig_ledTouchSet(bool bMode,int nColor,int nDelay);
    //壁障
    void sig_protectSet(bool bOpen);
    void sig_protectState();

    //==========audio==========
    void sig_ttsPlay(QString str_tts);
    void sig_ttsPlayParams(QString str_tts);
    void sig_ttsPlayFile(QString filePath);
    void sig_ttsSetVolume(int nVolume);
    void sig_ttsStop();

    void sig_asrBuild(QString filePath);
    void sig_asrStart(int nMaxTime);
    void sig_asrStop();

    void sig_mediaPlay(QString filePath);
    void sig_mediaVolume(int nVolume);
    void sig_mediaStop();

private slots:   
    void on_pushButton_conn_clicked();

    void on_pushButton_json_clicked();

    void on_pushButton_motor_clicked();

    void on_pushButton_audio_clicked();

    void on_pushButton_screenEx_clicked();

    void on_pushButton_config_clicked();

    void on_pushButton_pub_clicked();

    void on_pushButton_session_clicked();

    void on_pushButton_live_clicked();

    //================json=======================
    void on_pushButton_name_clicked();

    void on_pushButton_class_clicked();

    void on_pushButton_content_clicked();

    void on_pushButton_load_clicked();

    void on_pushButton_list_clicked();

    void on_pushButton_stop_clicked();

    void slot_getJsonState(bool state);

    void slot_getJsonList(QStringList m_list);

    //====================Motor===================
    //head
    void on_Btn_headEnable_clicked();

    void on_Btn_headPowerDown_clicked();

    void on_Btn_headLRInit_clicked();

    void on_Btn_headUDInit_clicked();

    void on_Btn_headLRAngle_clicked();

    void on_Btn_headUDAngle_clicked();

    //left hand
    void on_Btn_handLEnable_clicked();

    void on_Btn_handLPowerDown_clicked();

    void on_Btn_handLSwingInit_clicked();

    void on_Btn_handLExpandInit_clicked();

    void on_Btn_handLSwingAngle_clicked();

    void on_Btn_handLExpandAngle_clicked();

    //right hand
    void on_Btn_handREnable_clicked();
    void on_Btn_handRPowerDown_clicked();
    void on_Btn_handRSwingInit_clicked();
    void on_Btn_handRExpandInit_clicked();
    void on_Btn_handRSwingAngle_clicked();
    void on_Btn_handRExpandAngle_clicked();

    //wheel
    void on_Btn_wheelEnable_clicked();
    void on_Btn_wheelPowerDown_clicked();
    void on_Btn_wheelStop_clicked();
    void on_Btn_runRotate_clicked();
    void on_Btn_run_clicked();
    void on_Btn_runDiff_clicked();

    //sensor
    void on_Btn_battery_clicked();
    void on_Btn_sensorSonic_clicked();
    void on_Btn_sensorInfrared_clicked();
    void on_Btn_sensorWheel_clicked();

    void slot_sensorBatteryInfo(QString m_data);
    void slot_sensorSonicInfo(QString m_data);
    void slot_sensorInfraredInfo(QString m_data);
    void slot_sensorWheelInfo(QString m_data);

    //LED
    void on_Btn_headEye_clicked();
    void on_Btn_headEye2_clicked();
    void on_Btn_headEar_clicked();
    void on_Btn_bodyLed_clicked();
    void on_Btn_touchSet_clicked();

    //壁障功能
    void on_Btn_protectSet_clicked();
    void on_Btn_protectState_clicked();
    void slot_getProtectState(bool state);

    //===============audio=======================
    void on_Btn_ttsPlay_clicked();

    void on_Btn_ttsPlayParams_clicked();

    void on_Btn_ttsPlayFile_clicked();

    void on_Btn_ttsSetVolume_clicked();

    void on_Btn_ttsStop_clicked();

    void slot_ttsState(bool m_bPlaying);

    void on_Btn_asrBulid_clicked();

    void on_Btn_asrStart_clicked();

    void on_Btn_asrStop_clicked();

    void on_Btn_mediaPlay_clicked();

    void on_Btn_mediaSetVolume_clicked();

    void on_Btn_mediaStop_clicked();

    void slot_getMediaState(bool state);

    //=============system============
    void on_Btn_setSystemVolume_clicked();

    void on_Btn_getSystemVolume_clicked();

    void on_Btn_setSystemCmdVolume_clicked();

    //================pub==============
    void on_Btn_pub_clicked();

    void on_Btn_sub_clicked();

    //==============session=============
    void on_Btn_session_clicked();

    //===============live=================
    void on_Btn_liveStart_clicked();

    void on_Btn_liveStop_clicked();

private:
    Ui::DlgMain *ui;

    QString m_ip;
    QSettings *pr_setting;


};

#endif // DLGMAIN_H
